<template>
  <div>
    <el-form :model="pubForm" ref="userForm" :rules="rules">
        <el-form-item label="发货方式:" :label-width="formLabelWidth" prop="deliveryType">
             <el-select v-model="pubForm.deliveryType" placeholder="发货方式" @change="aaa">
             <el-option label="商家发货" value="Self"></el-option>
             <el-option label="物流配送" value="Express"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item v-if="pubForm.deliveryType != 'Self'" label="物流/快递单号1:" :label-width="formLabelWidth" prop="etc1">
            <el-input placeholder="请输入物流/快递单号" v-model="pubForm.etc1"></el-input>
        </el-form-item>
        <el-form-item v-if="pubForm.deliveryType != 'Self'" label="物流/快递单号2:" :label-width="formLabelWidth">
            <el-input placeholder="请输入物流/快递单号" v-model="pubForm.etc2"></el-input>
        </el-form-item>
    </el-form>
    <div class="dialog-footer">
    <el-button size="small" @click="quxiao">取 消</el-button>
    <el-button size="small" type="primary" @click="addcinge">确 定</el-button>
  </div>

  </div>
</template>

<script>
import {userdeliver} from "@/api/roles";
export default {
  props:{
    childata:{
      type: Object,
      require: true
    },
     },
 data () {
    return {
    formLabelWidth:'130px',
    pubForm:{
        deliveryType:'',
        etc1:null,
        etc2:null
    },
    rules:{
      deliveryType:[
       { required: true, message: '发货方式不能为空', trigger: 'blur' },
      ],
      etc1:[
       { required: true, message: '物流/快递单号不能为空', trigger: 'blur' },
      ]
       }
    }
 },
 created(){
    this.loachend()
 },
 methods:{
    loachend(){
          console.log('123',this.childata);
    },
    aaa(value){
        console.log(this.pubForm.deliveryType)
    },
      // 取消
  quxiao(){
    this.$emit('close')
  },
    // 确定
  async addcinge(){
       const params = new URLSearchParams(); // 创建URLSearchParams数据对象
          params.append("subOrderId", this.childata.subOrderId);
          params.append("deliveryType",this.pubForm.deliveryType);
          params.append("etc1",this.pubForm.etc1);
          params.append("etc2",this.pubForm.etc2);
          const res = await userdeliver(params);
          this.$message.success(res.msg)
          if(res.code == 200){
              this.$emit('close')
          }

   }
 }
}
</script>

<style scoped>
  .dialog-footer{
    width: 63%;
    margin-left: 63%;
   }
</style>